<template>
	<view class="content">
		<view class="list-wrap">
			<view class="cell" v-for="(item,index) in cashlist" :key="index">
				<view class="name" style="display: flex;justify-content: space-between;align-items: center;">
					<view>{{item.name}}</view>
				<view v-if="index == 0 || cashlist.length == 0" @click="toexchange">查看兑换记录</view>
				</view>
				<view class="list">
					<view class="cell-wrap">
						<view class="cell-l">
							<image class="bgimage" src="../../static/emptyCart.jpg" mode=""></image>
						</view>
						<view class="cell-r">
							<view>资产包数量：{{item.num}}</view>
							<view>兑换所需{{item.type==1?'消费积分':'消费奖励'}}：{{item.start_purchase}}</view>
							 <text>释放比例：{{item.interest}}</text>
							<view class="flex_">
								<view>释放数量：{{item.num}}</view>
								<view class="exchange" @click="exchange(index)">{{item.type_name}}</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				cashlist: [],
			}
		},
		onLoad() {
			this.getloadData()
		},
		onShow() {
			// this.getloadData()
		},
		methods: {
			toexchange(){
				uni.navigateTo({
					url:'../exchangelist/exchangelist?type=1'
				})
			},
			exchange(index) {
				uni.setStorageSync('cashdetail', this.cashlist[index])
				uni.navigateTo({
					url: '../cashlistdetail/cashlistdetail'
				})
			},
			getloadData() {
				console.log('1')
				let that = this;
				uni.request({
					url: 'https://www.ggshop1688.com/api/conduct/conductlist',
					data: {
						p: '1'
					},
					method: 'POST',
					header: {
						token: uni.getStorageSync('userInfo').token
					},
				}).then(data => {
					this.cashlist = data[1].data.data.list
				}).catch(err => {
					console.log(err)
				})
			},
		},

	}
</script>

<style lang="scss" scoped>
	.list-wrap {
		font-size: 12px;
		background-color: #f2f2f2;

		.cell {
			width: 100%;
			padding: 20upx;

			.name {
				padding: 20upx 0px;
			}

			.list {
				border: 1px solid #f2f2f2;
				border-radius: 7px;
				padding: 20upx 0px 20upx 20upx;
				background-color: #fff;

				.cell-wrap {
					display: flex;

					.cell-l {
						width: 160upx;
						height: 160upx;
						margin-right: 20upx;

						.bgimage {
							width: 100%;
							height: 100%;
						}
					}

					.cell-r {
						width: 73%;
						display: flex;
						flex-direction: column;
						justify-content: space-between;

						.flex_ {
							// margin-top: 80upx;
							display: -webkit-box;
							display: -webkit-flex;
							display: flex;
							justify-content: space-between;
							align-items: center;

							.exchange {
								width: 140upx;
								border-radius: 3px;
								height: 40upx;
								line-height: 40upx;
								background-color: #027aff;
								color: #fff;
								text-align: center;
							}
						}
					}
				}
			}
		}
	}
</style>
